package com.itheima.service.db.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.domain.vo.PageBeanVo;
import com.itheima.mapper.AnnouncementMapper;
import com.itheima.service.db.AnnouncementService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class AnnouncementServiceImpl implements AnnouncementService {

    @Autowired
    private AnnouncementMapper announcementMapper;

    @Override
    public PageBeanVo findAnnouncement(Integer pageNum, Integer pageSize) {
        //开启分页
        IPage page =new Page(pageNum,pageSize);

        //调用分页查询
        page = announcementMapper.findAnnouncement(page);

        //构造返回
        return new PageBeanVo(pageNum,pageSize,page.getTotal(),page.getRecords());
    }
}
